<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input @keyup.enter.native="loadData"  clearable size="small"  style="width: 200px;" class="filter-item" placeholder="商品编码" v-model="params.goodsNo"></el-input>
      <el-button class="filter-item" type="primary"   size="small"  v-waves icon="el-icon-search" @click="loadData">搜索</el-button>
    </div>
    <el-table :data="list"      :height="tableHeight"
  @sort-change="sortChange" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
      style="width: 100%">
      <el-table-column align="center" type="index" label="序号" width="60" fixed="left">
      </el-table-column>
      <el-table-column prop="goodsNo" align="center" label="商品编码" width="140" fixed="left">
        <template slot-scope="scope">
          <span>{{scope.row.goodsNo}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="title" align="center" label="商品名称" width="90" fixed="left">
        <template slot-scope="scope">
          <span>{{scope.row.title}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="price" align="center" label="b2c售价" width="80">
        <template slot-scope="scope">
          <span>{{scope.row.b2cPrice}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="price" align="center" label="微信价" width="80">
        <template slot-scope="scope">
          <span>{{scope.row.price}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="points" align="center" label="积分价" width="80">
        <template slot-scope="scope">
          <span>{{scope.row.points}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="scategoryCode" align="center" label="小类编码" width="160" fixed="left">
        <template slot-scope="scope">
          <span>{{scope.row.scategoryCode}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="scategoryName" align="center" label="小类名称" width="100">
        <template slot-scope="scope">
          <span>{{scope.row.scategoryName}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="mcategoryCode" align="center" label="中类编码" width="80">
        <template slot-scope="scope">
          <span>{{scope.row.marketPrice}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="taxRate" align="center" label="税率" width="160">
        <template slot-scope="scope">
          <span>{{scope.row.taxRate}}</span>
        </template>
      </el-table-column>
      <el-table-column prop="barCode" align="center" label="条形码" width="130">
        <template slot-scope="scope">
          <span>{{scope.row.barCode}}</span>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="params.pageNo"
        :page-sizes="[10,20,30,50]" :page-size="params.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { Loading } from 'element-ui'
export default {
  components: {
  },
  data () {
    return {
      tableHeight: 400,
      hasNewGoodRules: false,
      uillUpdateImg: false,
      isAddingRule: false,
      total: 0,

      params: {
        pageSize: 10,
        pageNo: 1
      },
      ruleDialogVisible: false,
    }
  },

  created () {
    this.tableHeight = window.innerHeight - 320
    this.loadData()
  },
  methods: {
    loadData () {
      let id = this.$route.query.id
      this.$post('/admin/goods_price_import/list_data', {id, ...this.params}).then(data => {
        this.list = data.rows
        this.total = data.total
      })
    },
    handleCurrentChange () {
      this.loadData()
    },
    handleSizeChange (val) {
      this.params.pageSize = parseInt(`${val}`)
      this.loadData()
    },
  }
}
</script>
<style scoped>
.avatar {
  width: 100px;
  display: block;
  margin: 0 auto;
  height: 100px;
}
.btns {
  padding-left: 15px;
  text-align: left;
}
.btns /deep/ button {
  margin-top: 10px;
  margin-bottom: 10px;
}
</style>
